<template>
  <el-dialog
    v-model="dialogVisible"
    :title="props.options.config.title||'标题'"
    width="500"
    v-bind="props.options.config"
  >
    <div>This is a message</div>
    <component ref="componentRef" :is="props.component" :data="props.options.data" />
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleCancel">取消</el-button>
        <el-button type="primary" @click="handleConfirm">确定</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
const props = defineProps({
  component: {
    type: Object,
    default: () => { }
  },
  options: {
    type: Object,
    default: () => { }
  }
})

const dialogVisible = ref(false)
const componentRef = ref()

const open = () => {
  dialogVisible.value = true
  
}
const handleClose = () => {
}
const handleCancel = () => {
}
const handleConfirm = async () => {
  try {
    let res = await componentRef.value.submit()
    dialogVisible.value = false
    props.options.confirm()
  }catch(err) { }
}
defineExpose({ open });
</script>

<style lang="scss" scoped>

</style>
